/*
 * @Author: dadadaXU 1413107032@qq.com
 * @Date: 2025-02-19 11:02:52
 * @LastEditors: dadadaXU 1413107032@qq.com
 * @LastEditTime: 2025-02-20 13:10:38
 * @FilePath: \LeetCode\104.二叉树的最大深度.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @lc app=leetcode.cn id=104 lang=cpp
 *
 * [104] 二叉树的最大深度
 */

#include "BinaryTree.hpp"

// @lc code=start

class Solution
{
public:
    int maxDepth(TreeNode *root)
    {
        if (root == nullptr)
            return 0;

        int leftTreeHigh = maxDepth(root->left);
        int rightTreeHigh = maxDepth(root->right);

        if (leftTreeHigh > rightTreeHigh)
            return leftTreeHigh + 1;
        else
            return rightTreeHigh + 1;
    }
};
// @lc code=end

int main(void)
{
    Solution solution;
    BinaryTree tree({4, -7, -3, NULL_NODE, NULL_NODE, -9, -3, 9, -7, -4, NULL_NODE, 6, NULL_NODE, -6, -6, NULL_NODE, NULL_NODE, 0, 6, 5, NULL_NODE, 9, NULL_NODE, NULL_NODE, -1, -4, NULL_NODE, NULL_NODE, NULL_NODE, -2});

    std::cout << solution.maxDepth(tree.rootNode_) << std::endl;

    return 0;
}